<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: SimpleNetwLayer Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00197.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="#pri-methods">Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">SimpleNetwLayer Class Reference<div class="ingroups"><a class="el" href="a00528.html">CSMAMac example - Classes from the CSMAMac example</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="SimpleNetwLayer" --><!-- doxytag: inherits="BaseModule" -->
<p>This is an implementation of a simple network layer which provides only some simple routing (next hop) and message forwarding (only switches).  
 <a href="a00197.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00239_source.html">SimpleNetwLayer.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for SimpleNetwLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a01009.png" border="0" usemap="#SimpleNetwLayer_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for SimpleNetwLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a01010.png" border="0" usemap="#SimpleNetwLayer_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a01011.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3f2e9c8431b75798f9d170d4c41501a4"></a><!-- doxytag: member="SimpleNetwLayer::netwpkt_t" ref="a3f2e9c8431b75798f9d170d4c41501a4" args="" -->
typedef NetwPkt&#160;</td><td class="memItemRight" valign="bottom"><b>netwpkt_t</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aca02a85d3117f0db3f7de76aace2b55c"></a><!-- doxytag: member="SimpleNetwLayer::netwpkt_ptr_t" ref="aca02a85d3117f0db3f7de76aace2b55c" args="" -->
typedef netwpkt_t *&#160;</td><td class="memItemRight" valign="bottom"><b>netwpkt_ptr_t</b></td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00197.html#a20a43187e836ef7fb9c26a6132b3b77a">initialize</a> (int stage)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Basic initialization for all modules.  <a href="#a20a43187e836ef7fb9c26a6132b3b77a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaa9b0e59e71d913a0bc99f94937e4f05"></a><!-- doxytag: member="SimpleNetwLayer::handleMessage" ref="aaa9b0e59e71d913a0bc99f94937e4f05" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><b>handleMessage</b> (cMessage *msg)</td></tr>
<tr><td colspan="2"><h2><a name="pro-types"></a>
Protected Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>NetwPktKind</b> { <b>HELLO_WORLD</b> =  4200, 
<b>JABBER</b>, 
<b>START_TO_JABBER</b>
 }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5aa120d443d2ede2cc50e682ecc24fa9"></a><!-- doxytag: member="SimpleNetwLayer::RoutingTable" ref="a5aa120d443d2ede2cc50e682ecc24fa9" args="" -->
typedef std::map<br class="typebreak"/>
&lt; <a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a>, <br class="typebreak"/>
<a class="el" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210">LAddress::L2Type</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>RoutingTable</b></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac3193be4e1d6fef90e4d11dcfb5ed548"></a><!-- doxytag: member="SimpleNetwLayer::scheduleJabbering" ref="ac3193be4e1d6fef90e4d11dcfb5ed548" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>scheduleJabbering</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6bb1c14cc91edf63fbd14094d54d360c"></a><!-- doxytag: member="SimpleNetwLayer::broadcastHelloWorld" ref="a6bb1c14cc91edf63fbd14094d54d360c" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>broadcastHelloWorld</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3753816b0cd2b1a4d3853478aa364e33"></a><!-- doxytag: member="SimpleNetwLayer::sendDown" ref="a3753816b0cd2b1a4d3853478aa364e33" args="(cPacket *pkt)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>sendDown</b> (cPacket *pkt)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a04260efc84484057dde43c172172bd70"></a><!-- doxytag: member="SimpleNetwLayer::forwardPacket" ref="a04260efc84484057dde43c172172bd70" args="(netwpkt_ptr_t pkt, const LAddress::L2Type &amp;nextHop)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>forwardPacket</b> (netwpkt_ptr_t pkt, const <a class="el" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210">LAddress::L2Type</a> &amp;nextHop)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af0b8624057339fb519562a5b6ef049c7"></a><!-- doxytag: member="SimpleNetwLayer::handleHelloWorld" ref="af0b8624057339fb519562a5b6ef049c7" args="(netwpkt_ptr_t pkt)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>handleHelloWorld</b> (netwpkt_ptr_t pkt)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9ef840887cbe3ea722d44ac83a1047e0"></a><!-- doxytag: member="SimpleNetwLayer::jabberToSomeone" ref="a9ef840887cbe3ea722d44ac83a1047e0" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>jabberToSomeone</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abc0e5c675ff3f0230cdc91468b705914"></a><!-- doxytag: member="SimpleNetwLayer::handleIncomingJabber" ref="abc0e5c675ff3f0230cdc91468b705914" args="(netwpkt_ptr_t pkt)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>handleIncomingJabber</b> (netwpkt_ptr_t pkt)</td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab61a4f00f3f8d2b3637c295f95b5fc8c"></a><!-- doxytag: member="SimpleNetwLayer::isSwitch" ref="ab61a4f00f3f8d2b3637c295f95b5fc8c" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>isSwitch</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae44adf1777151868d82ca8aba469378b"></a><!-- doxytag: member="SimpleNetwLayer::boredTime" ref="ae44adf1777151868d82ca8aba469378b" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00197.html#ae44adf1777151868d82ca8aba469378b">boredTime</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">time after when the module gets bored and starts jabbering. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae0f6b3a439c56cd2275a3f10d8a9a691"></a><!-- doxytag: member="SimpleNetwLayer::maxTtl" ref="ae0f6b3a439c56cd2275a3f10d8a9a691" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>maxTtl</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aafb836d0526cd5fab1623cfdb2c1d6d3"></a><!-- doxytag: member="SimpleNetwLayer::ip" ref="aafb836d0526cd5fab1623cfdb2c1d6d3" args="" -->
<a class="el" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4">LAddress::L3Type</a>&#160;</td><td class="memItemRight" valign="bottom"><b>ip</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a58834b1edd6cc63bcd522581cc0250ae"></a><!-- doxytag: member="SimpleNetwLayer::dataIn" ref="a58834b1edd6cc63bcd522581cc0250ae" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>dataIn</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a532bbd6a5172956ed9ae000f55fae8cd"></a><!-- doxytag: member="SimpleNetwLayer::dataOut" ref="a532bbd6a5172956ed9ae000f55fae8cd" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>dataOut</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a926095a2ae602b9a2773349160b12dea"></a><!-- doxytag: member="SimpleNetwLayer::startJabberTimer" ref="a926095a2ae602b9a2773349160b12dea" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>startJabberTimer</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abc490acad686c553452e30d46eca00bc"></a><!-- doxytag: member="SimpleNetwLayer::runningSeqNumber" ref="abc490acad686c553452e30d46eca00bc" args="" -->
unsigned long&#160;</td><td class="memItemRight" valign="bottom"><b>runningSeqNumber</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa4b573bb29f586e194db8ac015b99e99"></a><!-- doxytag: member="SimpleNetwLayer::routingTable" ref="aa4b573bb29f586e194db8ac015b99e99" args="" -->
RoutingTable&#160;</td><td class="memItemRight" valign="bottom"><b>routingTable</b></td></tr>
<tr><td colspan="2"><h2><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab080a3c4f30b630e534147527f51c861"></a><!-- doxytag: member="SimpleNetwLayer::SimpleNetwLayer" ref="ab080a3c4f30b630e534147527f51c861" args="(const SimpleNetwLayer &amp;)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00197.html#ab080a3c4f30b630e534147527f51c861">SimpleNetwLayer</a> (const <a class="el" href="a00197.html">SimpleNetwLayer</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor is not allowed. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a76441caa603cc1d8852254c7e46c169b"></a><!-- doxytag: member="SimpleNetwLayer::operator=" ref="a76441caa603cc1d8852254c7e46c169b" args="(const SimpleNetwLayer &amp;)" -->
<a class="el" href="a00197.html">SimpleNetwLayer</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00197.html#a76441caa603cc1d8852254c7e46c169b">operator=</a> (const <a class="el" href="a00197.html">SimpleNetwLayer</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment operator is not allowed. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>This is an implementation of a simple network layer which provides only some simple routing (next hop) and message forwarding (only switches). </p>
<p>This network layer isn't a real network layer its only purpose is to provide some message sending for the CSMA-Mac layer.</p>
<p>At first there is a small "saying hello"-phase where the several network layers saying hello to each other and creating their routing table.</p>
<p>After that phase the non-switch instances start to babbling randomly to other instances without caring if they here them. The switch instances does only provide packet forwarding from there on.</p>
<p>The several instances can babble directly to each other or over a switch instance. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a20a43187e836ef7fb9c26a6132b3b77a"></a><!-- doxytag: member="SimpleNetwLayer::initialize" ref="a20a43187e836ef7fb9c26a6132b3b77a" args="(int stage)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void SimpleNetwLayer::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Basic initialization for all modules. </p>
<p>Subscription should be in stage==0, and firing notifications in stage==1 or later.</p>
<p>NOTE: You have to call this in the <a class="el" href="a00197.html#a20a43187e836ef7fb9c26a6132b3b77a" title="Basic initialization for all modules.">initialize()</a> function of the inherited class! </p>

<p>Reimplemented from <a class="el" href="a00027.html#a03030e439aaf030c83da6e71e8be2f80">BaseModule</a>.</p>

<p>References <a class="el" href="a00197.html#ae44adf1777151868d82ca8aba469378b">boredTime</a>, and <a class="el" href="a00027.html#aabf0226159b22b46e70031fd3bb3b1b2">BaseModule::findHost()</a>.</p>
<div class="fragment"><pre class="fragment">                                    {

    <span class="keywordflow">if</span>(stage == 0){
      dataOut = findGate(<span class="stringliteral">&quot;lowerLayerOut&quot;</span>);
      dataIn = findGate(<span class="stringliteral">&quot;lowerLayerIn&quot;</span>);

      isSwitch = par(<span class="stringliteral">&quot;isSwitch&quot;</span>).boolValue();

      <span class="keywordflow">if</span>(isSwitch) {
        <a class="code" href="a00027.html#aabf0226159b22b46e70031fd3bb3b1b2" title="Function to get a pointer to the host module.">FindModule&lt;&gt;::findHost</a>(<span class="keyword">this</span>)-&gt;getDisplayString().setTagArg(<span class="stringliteral">&quot;i&quot;</span>,0,<span class="stringliteral">&quot;device/accesspoint&quot;</span>);
      }
      ip = <a class="code" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4" title="Type definition for a L3 (Network) address.">LAddress::L3Type</a>(par(<span class="stringliteral">&quot;ip&quot;</span>).longValue());
      maxTtl = par(<span class="stringliteral">&quot;maxTtl&quot;</span>).longValue();
      <a class="code" href="a00197.html#ae44adf1777151868d82ca8aba469378b" title="time after when the module gets bored and starts jabbering.">boredTime</a> = par(<span class="stringliteral">&quot;boredTime&quot;</span>).doubleValue();
    } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(stage == 1) {
      startJabberTimer = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;jabber!&quot;</span>, START_TO_JABBER);
      broadcastHelloWorld();
    }
  }
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/examples/CSMAMac/<a class="el" href="a00239_source.html">SimpleNetwLayer.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00197.html">SimpleNetwLayer</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
